package com.wc.fortnight_blue_bridge.Q231125.Q8729;

import java.util.Scanner;

/**
 * @Author congege
 * @Description
 * @Date Created in 2023/11/25-22:39
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long n = sc.nextLong();
        long q = sc.nextInt();
        while (q-- > 0) {
            long num = sc.nextLong();
            // 复原原来的好位置
            num += 1;
            // 去除第一行
            num -= 2;
            long row;
            long col;
            // 说明在第一行
            if (num <= 0) {
                num += 2;
                row = 1;
                col = num;
                System.out.println(row + " " + col);
                continue;
            }
            row = num / 3 + 1;
            if (num % 3 > 0) {
                row++;
            }
            col = row + (num % 3 == 0 ? 3 : num % 3) - 2;

            System.out.println(row + " " + col);
        }
    }
}
